#test data
task = require("./api/taskApi.js")
express = require("express")
app = express()

i = 1

counter = ->
	i++
	console.log("服务器访问被访问次数: i = " + i)

app.get "/task/:id", (req, res)->
	res.writeHead(200, "Content-Type": "application/json; charset=UTF-8")
	task.getTask().each (t)->
		res.write JSON.stringify t
	counter()
	res.end()

app.get "/tasks", (req, res)->
	res.writeHead(200, "Content-Type": "application/json; charset=UTF-8")
	res.write JSON.stringify task.getTasks()
	counter()
	res.end()

app.listen(9002)
console.log("服务已启动！")